import 'package:shopping_group/modle/login/entity/dv_entity.dart';
import 'dart:convert';

class CommoSpec4AppRecordEntity {
  //ID
  String id = '';
  //商品名称
  String name = '';
  //商品图文说明
  String remark = '';
  //商品类型
  String type = '';
  //商品类型名称
  String typeName = '';
  //图片文件路径
  String imgUrl = '';
  //商品出价
  String outPrice = '';
  //
  String inPrice = '';
  //是否作为复购商品
  String isReBuy = '';
  //已销售数量
  String hadShopCt = '';
  //图片URL列表
  List<String> lstImgUrl = [];
  //商品详情图片URL列表"
  List<String> lstRemarkImgUrl = [];
  String openType = '';
  String orderId = '';
  //用户与团规格关联标识，注意对于复购商品此字段必定有值
  String custGroupsRelaId = '';
  String selectId = '';
  //支付金额生成标识
  String payUuid = "";

  //实际应支付金额
  String realCharge = "0.00";
  //验证商品
  DvEntity valEntity = DvEntity();
  String count = '1';

  String giftRemark = '';
  String shopCt = "";
  List<LzCommoOptsModel> lstCommoOptsModels = [];

  CommoSpec4AppRecordEntity(
      {this.id,
      this.custGroupsRelaId,
      this.payUuid,
      this.realCharge,
      this.name,
      this.remark,
      this.type,
      this.typeName,
      this.imgUrl,
      this.inPrice,
      this.outPrice,
      this.isReBuy,
      this.shopCt,
      this.lstImgUrl,
      this.giftRemark,
      this.lstRemarkImgUrl,
      this.lstCommoOptsModels,
      this.hadShopCt});

  CommoSpec4AppRecordEntity.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    custGroupsRelaId = json['custGroupsRelaId'];
    payUuid = json['payUuid'];
    realCharge = json['realCharge'];
    name = json['name'];
    remark = json['remark'];
    type = json['type'];
    typeName = json['typeName'];
    imgUrl = json['imgUrl'];
    outPrice = json['outPrice'];
    inPrice = json['inPrice'];
    isReBuy = json['isReBuy'];
    giftRemark = json["giftRemark"];

    shopCt = json["shopCt"];

    hadShopCt = json['hadShopCt'];
    if (json['lstImgUrl'] != null) {
      lstImgUrl = new List<String>();
      json['lstImgUrl'].forEach((v) {
        lstImgUrl.add(v);
      });
    }

    if (json['lstRemarkImgUrl'] != null) {
      lstRemarkImgUrl = new List<String>();
      json['lstRemarkImgUrl'].forEach((v) {
        lstRemarkImgUrl.add(v);
      });
    }

    if (json['lstCommoOpts'] != null) {
      json['lstCommoOpts'].forEach((v) {
        lstCommoOptsModels.add(LzCommoOptsModel.fromMap(v));
      });
    }
  }
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['custGroupsRelaId'] = this.custGroupsRelaId;
    data['payUuid'] = this.payUuid;
    data['realCharge'] = this.realCharge;
    data['name'] = this.name;
    data['remark'] = this.remark;
    data['type'] = this.type;
    data['typeName'] = this.typeName;
    data['imgUrl'] = this.imgUrl;
    data['outPrice'] = this.outPrice;
    data['inPrice'] = this.inPrice;
    data['giftRemark'] = this.giftRemark;
    data['isReBuy'] = this.isReBuy;
    data['hadShopCt'] = this.hadShopCt;
    if (this.lstImgUrl != null) {
      data['lstImgUrl'] = this.lstImgUrl.map((v) => v).toList();
    }

    if (this.lstRemarkImgUrl != null) {
      data['lstRemarkImgUrl'] = this.lstRemarkImgUrl.map((v) => v).toList();
    }
    if (this.lstCommoOptsModels != null) {
      data['lstCommoOpts'] = this.lstCommoOptsModels.map((e) => e.toMap()).toList();
    }
    return data;
  }
}

// To parse this JSON data, do
//
//     final lzCommoOptsModel = lzCommoOptsModelFromMap(jsonString);

List<LzCommoOptsModel> lzCommoOptsModelFromMap(String str) =>
    List<LzCommoOptsModel>.from(json.decode(str).map((x) => LzCommoOptsModel.fromMap(x)));

String lzCommoOptsModelToMap(List<LzCommoOptsModel> data) =>
    json.encode(List<dynamic>.from(data.map((x) => x.toMap())));

class LzCommoOptsModel {
  LzCommoOptsModel({
    this.optsCode,
    this.optsName,
    this.seq,
    this.columnCt,
    this.beMustSel,
    this.beSingleSel,
    this.lstCommoOpt,
  });

  String optsCode;
  String optsName;
  String seq;
  String columnCt;
  String beMustSel;
  String beSingleSel;
  List<LstCommoOpt> lstCommoOpt;

  factory LzCommoOptsModel.fromMap(Map<String, dynamic> json) => LzCommoOptsModel(
        optsCode: json["optsCode"] == null ? null : json["optsCode"],
        optsName: json["optsName"] == null ? null : json["optsName"],
        seq: json["seq"] == null ? null : json["seq"],
        beMustSel: json["beMustSel"] == null ? null : json["beMustSel"],
        beSingleSel: json["beSingleSel"] == null ? null : json["beSingleSel"],
        columnCt: json["columnCt"] == null ? null : json["columnCt"],
        lstCommoOpt: json["lstCommoOpt"] == null
            ? null
            : List<LstCommoOpt>.from(json["lstCommoOpt"].map((x) => LstCommoOpt.fromMap(x))),
      );

  Map<String, dynamic> toMap() => {
        "optsCode": optsCode == null ? null : optsCode,
        "optsName": optsName == null ? null : optsName,
        "seq": seq == null ? null : seq,
        "columnCt": columnCt == null ? null : columnCt,
        "beMustSel": beMustSel == null ? null : beMustSel,
        "beSingleSel": beSingleSel == null ? null : beSingleSel,
        "lstCommoOpt": lstCommoOpt == null ? null : List<dynamic>.from(lstCommoOpt.map((x) => x.toMap())),
      };
}

class LstCommoOpt {
  LstCommoOpt({
    this.optCode,
    this.optName,
    this.beSel,
    this.caJia,
    this.kuCunCt,
  });

  String optCode;
  String optName;
  String beSel;
  String caJia;
  String kuCunCt;

  factory LstCommoOpt.fromMap(Map<String, dynamic> json) => LstCommoOpt(
        optCode: json["optCode"] == null ? null : json["optCode"],
        optName: json["optName"] == null ? null : json["optName"],
        beSel: json["beSel"] == null ? null : json["beSel"],
        caJia: json["caJia"] == null ? null : json["caJia"],
        kuCunCt: json["kuCunCt"] == null ? null : json["kuCunCt"],
      );

  Map<String, dynamic> toMap() => {
        "optCode": optCode == null ? null : optCode,
        "optName": optName == null ? null : optName,
        "beSel": beSel == null ? null : beSel,
        "caJia": caJia == null ? null : caJia,
        "kuCunCt": kuCunCt == null ? null : kuCunCt,
      };
}
